package com.gome.ocean.service.cangologicservice.impl;

import java.util.List;

import org.apache.ibatis.session.RowBounds;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gome.ocean.dao.cango.CangoInstancesDAO;
import com.gome.ocean.dao.model.cango.CangoInstances;
import com.gome.ocean.service.cangologicservice.ICangoLogicService;

/**
 * @author zhangguoqing 2017年2月22日 下午8:06:34
 * @since 5.0.0
 */
@Service("iCangoLogicServiceImpl")
public class CangoLogicServiceImpl implements ICangoLogicService {

    private Logger Logger = LoggerFactory.getLogger(CangoLogicServiceImpl.class);

    @Autowired
    private CangoInstancesDAO cangoInstanceDao;

    @Override
    public List<CangoInstances> getAllBeanLists(Integer pageNum, Integer pageSize) {
        List<CangoInstances> list = cangoInstanceDao.findAllBean(new RowBounds(pageNum, pageSize));
        if (list != null && list.size() > 0) {
            return list;
        }
        return null;
    }

    @Override
    public List<CangoInstances> getAllBeanListsByProjectNames(Integer pageNum, Integer pageSize,
                                                              List<String> projectNames) {
        List<CangoInstances> list = cangoInstanceDao.findAllBeanByProjectName(new RowBounds(pageNum, pageSize),
            projectNames);
        if (list != null && list.size() > 0) {
            return list;
        }
        return null;
    }

    @Override
    public CangoInstances getBeanByInstanceName(String instanceName) {
        return cangoInstanceDao.findByName(instanceName);
    }

}
